package com.mahees.portfolio.domain

import com.mahees.portfolio.domain.DBFile;

import grails.test.*

class DBFileTests extends GrailsUnitTestCase {
	
	DBFile dBFile;
	byte[] fileBytes
	String fileRepresentation
	
    protected void setUp() {
        super.setUp()
		
		mockDomain(DBFile);
		
		fileRepresentation = "Jack Sparrow";
		
		dBFile = new DBFile();
		fileBytes = fileRepresentation.getBytes();
    }

    protected void tearDown() {
        super.tearDown()
    }

    void testEncodeBase64() {
		dBFile.encodeBase64(fileBytes);
		
		assert dBFile.content == "SmFjayBTcGFycm93";
    }
	
	void testDecodeBase64() {
		dBFile.content = "SmFjayBTcGFycm93"
		
		assert dBFile.decodeBase64() == fileBytes
		assert new String(dBFile.decodeBase64()) == fileRepresentation 
	}
}
